package me.atbar.moonlib.command;

import lombok.Getter;
import me.atbar.moonlib.Main;
import me.atbar.moonlib.command.commandmap.*;
import me.atbar.moonlib.version.VersionEnum;
import org.bukkit.command.Command;

/**
 * @author Administrator
 */
public class CommandRegister {

    @Getter
    private final Command command;

    public CommandRegister(Command command) {
        this.command = command;
    }

    public boolean register() {
        VersionEnum version = Main.getVersionEnum();
        if (version == VersionEnum.NOT_SUPPORT) {
            return false;
        }
        switch (version) {
            case VERSION_1_8 : {
                CraftServerInterface commandInterface = new Craft_v_1_8();
                commandInterface.registerCommand(command);
                return true;
            }
            case VERSION_1_9 : {
                CraftServerInterface commandInterface = new Craft_v_1_9();
                commandInterface.registerCommand(command);
                return true;
            }
            case VERSION_1_10 : {
                CraftServerInterface commandInterface = new Craft_v_1_10();
                commandInterface.registerCommand(command);
                return true;
            }
            case VERSION_1_11 : {
                CraftServerInterface commandInterface = new Craft_11();
                commandInterface.registerCommand(command);
                return true;
            }
            case VERSION_1_12 : {
                CraftServerInterface commandInterface = new Craft_After12();
                commandInterface.registerCommand(command);
                return true;
            }
            default: {
                return false;
            }
        }
    }

}
